<?php
/* ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1); */
session_start();
if (isset ( $_SESSION ['car_no'] )) {
	$car_no = $_SESSION ['car_no'];
	$startDateTime = $_POST ['startDateTime'];
	$endDateTime = $_POST ['endDateTime'];
	$journeyFrom = $_POST ['journeyFrom'];
	$journeyTo = $_POST ['journeyTo'];
	$placesVisited = $_POST ['placesVisited'];
	$amountFuelTopup = $_POST ['fuelTopupAmount'];
	$startOdometerReading = $_POST ['startOdometerReading'];
	$endOdometerReading = $_POST ['endOdometerReading'];
	$numPatients = $_POST ['numPatients'];
	$numDoctors = $_POST ['numDoctors'];
	$numAssistants = $_POST ['numAssistants'];
	$carComment = $_POST ['carComment'];
	$toolComment = $_POST ['toolComment'];
	$otherComment = $_POST ['otherComment'];
	
	include 'dbconnection.php';
	
	$sql = "INSERT INTO drive_record (CAR_NO,START_DATETIME,END_DATETIME,`FROM`,`TO`,VISITED_PLACES,AMOUNT_FUEL_TOPUP,START_ODOMETER,END_ODOMETER,NUM_PATIENTS,NUM_DOCTORS,NUM_ASSISTANTS,CAR_COMMENT,TOOL_COMMENT,REMARK,INSERT_DATETIME) VALUES ('" . $car_no . "','" . $startDateTime . "','" . $endDateTime . "','" . $journeyFrom . "','" . $journeyTo . "','" . $placesVisited . "'," . $amountFuelTopup . "," . $startOdometerReading . "," . $endOdometerReading . "," . $numPatients . "," . $numDoctors . "," . $numAssistants . ",'" . $carComment . "','" . $toolComment . "','" . $otherComment . "',now())";
	echo $sql;
	$num = mysql_query ( $sql );
	echo $num;
	if ($num) {
		header ( "Location:view.php" );
	}
	/* else {
		header ( "Location:addnew.php" );
	} */
	mysql_close ( $con );
}

?>